using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace EM.utility
{
    public class Counter
    {
        public int GetCounterValue(string COUNTERCODE)
        {
            DataSrv dsrv = new DataSrv();
            SqlCommand cmd  = new SqlCommand();
            DataTable dt = new DataTable();

            string sSQL = "DECLARE @COUNTERVALUE BIGINT ";
            sSQL += " EXEC SPGETCOUNTER @COUNTERCODE, @COUNTERVALUE OUTPUT";
            sSQL += " SELECT @COUNTERVALUE";

            cmd.CommandText = sSQL;
            cmd.Parameters.Add("@COUNTERCODE", SqlDbType.NVarChar).Value = COUNTERCODE;
            dt = dsrv.CreateDataTable(cmd, "TBLCOUNTER");

            return Convert.ToInt32(dt.Rows[0][0].ToString());
            
        }
    }
}
